#include <stdio.h>
#include <stdlib.h>
#include <string>

extern "C" {
    #include <lua.h>
    #include <lualib.h>
    #include <lauxlib.h>
    #include <luaconf.h>
}

int main(int argc, const char **argv) {
    lua_State *L = luaL_newstate();
    luaL_openlibs(L);
    int ret = luaL_dofile(L, "./test.lua");
    if (ret != 0) {
        perror("xxx");
        exit(-1);
    }

    lua_getglobal(L, "test");
    std::string str = "";
    str.resize(long(1e10), 'a');
    printf("len：%lu cap:%lu max_size:%lu\n", str.length(), str.capacity(), str.max_size());
    //lua_pushlstring(L, str.c_str(), str.length());
    lua_pushstring(L, str.c_str());

    ret = lua_pcall(L, 1, 0, 0);
    if (ret != 0) {
        perror("afd");
        exit(-1);
    }

    int top = lua_gettop(L);
    printf("top:%d\n", top);
    printf("%f %lu\n", 1e5, str.max_size());
    return 0;
}
